/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.POSBeerView;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "ScanTblKeg")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ScanTblKeg.findAll", query = "SELECT s FROM ScanTblKeg s"),
    @NamedQuery(name = "ScanTblKeg.findByKegID", query = "SELECT s FROM ScanTblKeg s WHERE s.kegID = :kegID"),
    @NamedQuery(name = "ScanTblKeg.findByKegType", query = "SELECT s FROM ScanTblKeg s WHERE s.kegType = :kegType"),
    @NamedQuery(name = "ScanTblKeg.findByKegBatch", query = "SELECT s FROM ScanTblKeg s WHERE s.kegBatch = :kegBatch"),
    @NamedQuery(name = "ScanTblKeg.findByDateSold", query = "SELECT s FROM ScanTblKeg s WHERE s.dateSold = :dateSold"),
    @NamedQuery(name = "ScanTblKeg.findByKegLost", query = "SELECT s FROM ScanTblKeg s WHERE s.kegLost = :kegLost"),
    @NamedQuery(name = "ScanTblKeg.findByKegOOC", query = "SELECT s FROM ScanTblKeg s WHERE s.kegOOC = :kegOOC"),
    @NamedQuery(name = "ScanTblKeg.findByScanTime", query = "SELECT s FROM ScanTblKeg s WHERE s.scanTime = :scanTime"),
    @NamedQuery(name = "ScanTblKeg.findByCustomer", query = "SELECT s FROM ScanTblKeg s WHERE s.kegCust.cId = ?1")})
public class ScanTblKeg implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "KegID")
    private Integer kegID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 80)
    @Column(name = "KegType")
    private String kegType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "KegBatch")
    private int kegBatch;
    @Column(name = "DateSold")
    @Temporal(TemporalType.DATE)
    private Date dateSold;
    @Basic(optional = false)
    @NotNull
    @Column(name = "kegLost")
    private boolean kegLost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "kegOOC")
    private boolean kegOOC;
    @Basic(optional = false)
    @NotNull
    @Column(name = "scanTime")
    @Temporal(TemporalType.TIME)
    private Date scanTime;
    @JoinColumn(name = "KegFGI", referencedColumnName = "FGIID", nullable=true)
    @ManyToOne(optional = true)
    private FinishedGoodsInventory kegFGI;
    @JoinColumn(name = "KegPackageID", referencedColumnName = "PackageTypeID")
    @ManyToOne(optional = false)
    private PackageType kegPackageID;
    @JoinColumn(name = "KegBeer", referencedColumnName = "BId", nullable=true)
    @ManyToOne(optional = true)
    private POSBeerView kegBeer;
    @JoinColumn(name = "KegCust", referencedColumnName = "CId", nullable=true)
    @ManyToOne(optional = true)
    private Customer kegCust;

    public ScanTblKeg() {
    }

    public ScanTblKeg(Integer kegID) {
        this.kegID = kegID;
    }

    public ScanTblKeg(Integer kegID, String kegType, int kegBatch, Date dateSold, boolean kegLost, boolean kegOOC, Date scanTime) {
        this.kegID = kegID;
        this.kegType = kegType;
        this.kegBatch = kegBatch;
        this.dateSold = dateSold;
        this.kegLost = kegLost;
        this.kegOOC = kegOOC;
        this.scanTime = scanTime;
    }

    public Integer getKegID() {
        return kegID;
    }

    public void setKegID(Integer kegID) {
        this.kegID = kegID;
    }

    public String getKegType() {
        return kegType;
    }

    public void setKegType(String kegType) {
        this.kegType = kegType;
    }

    public POSBeerView getKegBeer() {
        return kegBeer;
    }

    public void setKegBeer(POSBeerView kegBeer) {
        if(kegBeer != null && kegBeer.getbId()!=null){
            this.kegBeer = kegBeer;
        }
    }
    
    public void makeKegBeerNull(){
        this.kegBeer = null;
    }

    public Customer getKegCust() {
        return kegCust;
    }

    public void setKegCust(Customer kegCust) {
        //if(kegCust != null && kegCust.getCId()!=null){
            this.kegCust = kegCust;
        //}
    }
    
    public void makeKegCustNull(){
        this.kegCust = null;
    }

    public int getKegBatch() {
        return kegBatch;
    }

    public void setKegBatch(int kegBatch) {
        this.kegBatch = kegBatch;
    }

    public Date getDateSold() {
        return dateSold;
    }

    public void setDateSold(Date dateSold) {
        this.dateSold = dateSold;
    }

    public PackageType getKegPackageID() {
        return kegPackageID;
    }

    public void setKegPackageID(PackageType kegPackageID) {
        this.kegPackageID = kegPackageID;
    }

    public FinishedGoodsInventory getKegFGI() {
        return kegFGI;
    }

    public void setKegFGI(FinishedGoodsInventory kegFGI) {
        if(kegFGI != null && kegFGI.getFgiid()!=null){
            this.kegFGI = kegFGI;
        }
    }
    
    public void makeKegFGINull(){
        this.kegFGI = null;
    }

    public boolean getKegLost() {
        return kegLost;
    }

    public void setKegLost(boolean kegLost) {
        this.kegLost = kegLost;
    }

    public boolean getKegOOC() {
        return kegOOC;
    }

    public void setKegOOC(boolean kegOOC) {
        this.kegOOC = kegOOC;
    }

    public Date getScanTime() {
        return scanTime;
    }

    public void setScanTime(Date scanTime) {
        this.scanTime = scanTime;
    }


    @Override
    public int hashCode() {
        int hash = 0;
        hash += (kegID != null ? kegID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ScanTblKeg)) {
            return false;
        }
        ScanTblKeg other = (ScanTblKeg) object;
        if ((this.kegID == null && other.kegID != null) || (this.kegID != null && !this.kegID.equals(other.kegID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.ScanTblKeg[ kegID=" + kegID + " ]";
    }
    
}
